<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="什么是MongodbMongodb:是分布式文件存储的数据库，可扩展的高性能的数据存储方案  为什么学习Mongodb1.公司的项目使用mongodb的原因是:读&amp;gt;&amp;gt;写，Mongodb高性能及扩展能力源于天生分布式特性2.Mongodb的存储单元是BSON(Json的二进制形式)，没有传统关系型数据库的固定字段,代码更加简洁3.容错性强:一台机器挂了还有很多机器支撑缺点:1.分布式系统">
<meta property="og:type" content="article">
<meta property="og:title" content="mongodb教程">
<meta property="og:url" content="http://yoursite.com/2017/07/10/mongodb/mongodb/index.html">
<meta property="og:site_name" content="Tissan">
<meta property="og:description" content="什么是MongodbMongodb:是分布式文件存储的数据库，可扩展的高性能的数据存储方案  为什么学习Mongodb1.公司的项目使用mongodb的原因是:读&amp;gt;&amp;gt;写，Mongodb高性能及扩展能力源于天生分布式特性2.Mongodb的存储单元是BSON(Json的二进制形式)，没有传统关系型数据库的固定字段,代码更加简洁3.容错性强:一台机器挂了还有很多机器支撑缺点:1.分布式系统">
<meta property="og:image" content="http://yoursite.com/uploads/mongodb/mongodb命令.png">
<meta property="og:image" content="http://yoursite.com/uploads/mongodb/mongo-mapreduce1.jpg">
<meta property="og:image" content="http://yoursite.com/uploads/mongodb/mongodb-mapreduce2.png">
<meta property="og:image" content="http://yoursite.com/uploads/mongodb/mongo-index.png">
<meta property="og:image" content="http://yoursite.com/uploads/mongodb/mongo-index2.png">
<meta property="og:image" content="http://yoursite.com/uploads/mongodb/mongodb-regex.png">
<meta property="og:updated_time" content="2018-01-28T06:51:24.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="mongodb教程">
<meta name="twitter:description" content="什么是MongodbMongodb:是分布式文件存储的数据库，可扩展的高性能的数据存储方案  为什么学习Mongodb1.公司的项目使用mongodb的原因是:读&amp;gt;&amp;gt;写，Mongodb高性能及扩展能力源于天生分布式特性2.Mongodb的存储单元是BSON(Json的二进制形式)，没有传统关系型数据库的固定字段,代码更加简洁3.容错性强:一台机器挂了还有很多机器支撑缺点:1.分布式系统">
<meta name="twitter:image" content="http://yoursite.com/uploads/mongodb/mongodb命令.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 'undefined',
      author: 'Java程序员'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/07/10/mongodb/mongodb/"/>





  <title>mongodb教程 | Tissan</title>
  














</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Tissan</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/07/10/mongodb/mongodb/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="罗天翔">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Tissan">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">mongodb教程</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-07-10T16:12:09+08:00">
                2017-07-10
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/mongodb/" itemprop="url" rel="index">
                    <span itemprop="name">mongodb</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/2017/07/10/mongodb/mongodb/#SOHUCS" itemprop="discussionUrl">
                  <span id="changyan_count_unit" class="post-comments-count hc-comment-count" data-xid="2017/07/10/mongodb/mongodb/" itemprop="commentsCount"></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <h4 id="什么是Mongodb"><a href="#什么是Mongodb" class="headerlink" title="什么是Mongodb"></a>什么是Mongodb</h4><p>Mongodb:是分布式文件存储的数据库，可扩展的高性能的数据存储方案</p>
<hr>
<h4 id="为什么学习Mongodb"><a href="#为什么学习Mongodb" class="headerlink" title="为什么学习Mongodb"></a>为什么学习Mongodb</h4><p>1.公司的项目使用mongodb的原因是:读&gt;&gt;写，Mongodb高性能及扩展能力源于天生分布式特性<br>2.Mongodb的存储单元是BSON(Json的二进制形式)，没有传统关系型数据库的固定字段,代码更加简洁<br>3.容错性强:一台机器挂了还有很多机器支撑<br>缺点:<br>1.分布式系统存在的数据安全问题<br>2.分布式系统不能满足CAP定理<br>一致性(Consistency) (所有节点在同一时间具有相同的数据)<br>可用性(Availability) (保证每个请求不管成功或者失败都有响应)<br>分隔容忍(Partition tolerance) (系统中任意信息的丢失或失败不会影响系统的继续运作)</p>
<hr>
<h4 id="mongodb基本命令"><a href="#mongodb基本命令" class="headerlink" title="mongodb基本命令:"></a>mongodb基本命令:</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line">//连接</div><div class="line">/home/admin/mongo/bin/mongo -u weike -p iha0p1ng admin --port 27017</div><div class="line">/home/admin/mongo/bin/mongo -u `name` -p `password` `sysuser` --port `port`</div><div class="line">use DATABASE_NAME</div><div class="line">show dbs</div><div class="line">show tables</div><div class="line">//查询</div><div class="line">db.col.find().pretty() //显示所有文档</div><div class="line">db.col.find(&#123;&quot;likes&quot; : &#123;$gt : 100&#125;&#125;)</div><div class="line">db.col.find(&#123;likes : &#123;$lt :200, $gt : 100&#125;&#125;)</div><div class="line">//$lt lte gt gte</div><div class="line">db.col.find(&#123;&#125;,&#123;&quot;title&quot;:1,_id:0&#125;).limit(2)</div><div class="line"></div><div class="line">//聚合</div><div class="line">db.mycol.aggregate([&#123;$group : &#123;_id : &quot;$by_user&quot;, num_tutorial : &#123;$sum : 1&#125;&#125;&#125;])</div><div class="line">//select by_user, count(*) from mycol group by by_user</div></pre></td></tr></table></figure>
<hr>
<h4 id="MongoDB数据格式"><a href="#MongoDB数据格式" class="headerlink" title="MongoDB数据格式"></a>MongoDB数据格式</h4><p>1.ObjectId BSON类型数据  序列id(不是同步自增id，几台机器同步增加序列 费时费力)<br>时间戳+机器识别码+进程id+随机数( 也可以用自己生成的id代理new ObjectId())</p>
<p>其实也可以实现自动增长 getNextSequenceValue(中使用findAndModify保证原子性)</p>
<hr>
<h4 id="MongoDB-索引"><a href="#MongoDB-索引" class="headerlink" title="MongoDB 索引"></a>MongoDB 索引</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">//单一索引</div><div class="line">db.col.ensureIndex(&#123;&quot;title&quot;:1&#125;)</div><div class="line">//复合索引</div><div class="line">db.col.ensureIndex(&#123;&quot;title&quot;:1,&quot;description&quot;:-1&#125;)</div></pre></td></tr></table></figure>
<p><img src="/uploads/mongodb/mongodb命令.png" alt="流程图"></p>
<hr>
<h4 id="Mongodb-分片"><a href="#Mongodb-分片" class="headerlink" title="Mongodb 分片"></a>Mongodb 分片</h4><p>1.请求量大可以分摊压力<br>2.垂直扩展价格昂贵(1TB价格&gt;500*2GB)</p>
<hr>
<h4 id="MongoDB覆盖索引查询"><a href="#MongoDB覆盖索引查询" class="headerlink" title="MongoDB覆盖索引查询"></a>MongoDB覆盖索引查询</h4><p>1.索引数据存在于内存当中，从索引中获取数据比通过扫描文件快<br>2.查询字段是索引的一部分 &amp;&amp; 所有查询返回的字段在同一个索引中</p>
<p>例如:建立索引<br>db.users.ensureIndex({gender:1,user_name:1})<br>索引覆盖下面的查询:从内存中读取<br>db.users.find({gender:”M”},{user_name:1,_id:0})<br>下面的查询没有排除_id，所以不覆盖<br>db.users.find({gender:”M”},{user_name:1})</p>
<p>不能使用覆盖查询的情况:</p>
<blockquote>
<p>所有的索引字段是一个数组(都是数组没有关系 )<br>所有的索引字段是一个子文档(索引是一个field的子文档没关系)</p>
</blockquote>
<hr>
<h4 id="Mongodb查询分析"><a href="#Mongodb查询分析" class="headerlink" title="Mongodb查询分析"></a>Mongodb查询分析</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div></pre></td><td class="code"><pre><div class="line">&#123;</div><div class="line">    //使用的btree索引</div><div class="line">   &quot;cursor&quot; : &quot;BtreeCursor gender_1_user_name_1&quot;,</div><div class="line">   &quot;isMultiKey&quot; : false,</div><div class="line">   //文档数量</div><div class="line">   &quot;n&quot; : 1,</div><div class="line">   //一共扫描了多少文档,让数值和返回文档的数量越接近越好</div><div class="line">   &quot;nscannedObjects&quot; : 0,</div><div class="line">   &quot;nscanned&quot; : 1,</div><div class="line">   &quot;nscannedObjectsAllPlans&quot; : 0,</div><div class="line">   &quot;nscannedAllPlans&quot; : 1,</div><div class="line">   &quot;scanAndOrder&quot; : false,</div><div class="line">   //使用了索引</div><div class="line">   &quot;indexOnly&quot; : true,</div><div class="line">   &quot;nYields&quot; : 0,</div><div class="line">   &quot;nChunkSkips&quot; : 0,</div><div class="line">   &quot;millis&quot; : 0,</div><div class="line">   //当前查询所使用的具体的索引</div><div class="line">   &quot;indexBounds&quot; : &#123;</div><div class="line">      &quot;gender&quot; : [</div><div class="line">         [</div><div class="line">            &quot;M&quot;,</div><div class="line">            &quot;M&quot;</div><div class="line">         ]</div><div class="line">      ],</div><div class="line">      &quot;user_name&quot; : [</div><div class="line">         [</div><div class="line">            &#123;</div><div class="line">               &quot;$minElement&quot; : 1</div><div class="line">            &#125;,</div><div class="line">            &#123;</div><div class="line">               &quot;$maxElement&quot; : 1</div><div class="line">            &#125;</div><div class="line">         ]</div><div class="line">      ]</div><div class="line">   &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<hr>
<h4 id="原子操作命令"><a href="#原子操作命令" class="headerlink" title="原子操作命令"></a>原子操作命令</h4><p>$set : insertOrUpdate 针对于某个key<br>$unset : deleteKey<br>$inc : 针对于key +/-<br>$push : push to array,如果没有init array<br>$pushAll : array push array<br>$pull : array delete value<br>$addToSet : push to set<br>$pop : delete first/last in array<br>$rename : rename field<br>$bit : 位操作 针对某个integer field</p>
<hr>
<h4 id="Mongodb索引限制"><a href="#Mongodb索引限制" class="headerlink" title="Mongodb索引限制"></a>Mongodb索引限制</h4><p>1.索引占据空间，更新插入都需要对索引操作，经常query的话建议使用index<br>2.index大小不超过内存大小<br>3.正则,$nin,#not,算术符$mod,$where子句 都不能使用索引<br>4.索引字段的值超过<code>索引键</code>的限制，不会创建索引<br>5.index个数&lt;64  indexNameLength&lt;128  union_idx&lt;31个field</p>
<hr>
<h4 id="Mongodb-MapReduce"><a href="#Mongodb-MapReduce" class="headerlink" title="Mongodb MapReduce"></a>Mongodb MapReduce</h4><p><img src="/uploads/mongodb/mongo-mapreduce1.jpg" alt="流程图"><br>使用Map-Reduce来选取state为2的对象<br><img src="/uploads/mongodb/mongodb-mapreduce2.png" alt="流程图"></p>
<hr>
<h4 id="Mongodb-全文检索"><a href="#Mongodb-全文检索" class="headerlink" title="Mongodb 全文检索"></a>Mongodb 全文检索</h4><p>Mongodb 全文检索<br>像<code>字典</code>那样对每个单词建立索引，不支持中文全文索引</p>
<blockquote>
<p>db.table.find({$text:{$search:”tissan”}})</p>
</blockquote>
<p><img src="/uploads/mongodb/mongo-index.png" alt="流程图"></p>
<blockquote>
<p>db.table.ensureIndex({name:”text”})<br>db.table.find({$text:{$search:”tissan”}})</p>
</blockquote>
<p><img src="/uploads/mongodb/mongo-index2.png" alt="流程图"></p>
<hr>
<h4 id="Mongodb-正则表达式"><a href="#Mongodb-正则表达式" class="headerlink" title="Mongodb 正则表达式"></a>Mongodb 正则表达式</h4><blockquote>
<p>db.table.find({name:{$regex:”Tiss”}})<br>db.table.find({name:{$regex:”tiss”,$options:”$i”}})<br><img src="/uploads/mongodb/mongodb-regex.png" alt="流程图"></p>
</blockquote>
<hr>
<h4 id="Mongodb-固定集合"><a href="#Mongodb-固定集合" class="headerlink" title="Mongodb 固定集合"></a>Mongodb 固定集合</h4><blockquote>
<p>insert,query速度极快<br>能够自动delete掉老数据<br>用法：存储日志，缓存少量文档</p>
</blockquote>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/uploads/wechat.png" alt="罗天翔 WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="/uploads/ali.jpg" alt="罗天翔 Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/07/10/network/DDOS/" rel="next" title="DDos">
                <i class="fa fa-chevron-left"></i> DDos
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/07/14/rocketmq/消息订阅/" rel="prev" title="消息订阅.md">
                消息订阅.md <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="SOHUCS"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/uploads/avatar.jpg"
               alt="罗天翔" />
          <p class="site-author-name" itemprop="name">罗天翔</p>
           
              <p class="site-description motion-element" itemprop="description">一次就把事情做对.</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives/">
                <span class="site-state-item-count">74</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">15</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/louiegit/" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="" target="_blank" title="微信">
                  
                    <i class="fa fa-fw fa-wechat"></i>
                  
                  微信
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#什么是Mongodb"><span class="nav-number">1.</span> <span class="nav-text">什么是Mongodb</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#为什么学习Mongodb"><span class="nav-number">2.</span> <span class="nav-text">为什么学习Mongodb</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#mongodb基本命令"><span class="nav-number">3.</span> <span class="nav-text">mongodb基本命令:</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#MongoDB数据格式"><span class="nav-number">4.</span> <span class="nav-text">MongoDB数据格式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#MongoDB-索引"><span class="nav-number">5.</span> <span class="nav-text">MongoDB 索引</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Mongodb-分片"><span class="nav-number">6.</span> <span class="nav-text">Mongodb 分片</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#MongoDB覆盖索引查询"><span class="nav-number">7.</span> <span class="nav-text">MongoDB覆盖索引查询</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Mongodb查询分析"><span class="nav-number">8.</span> <span class="nav-text">Mongodb查询分析</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#原子操作命令"><span class="nav-number">9.</span> <span class="nav-text">原子操作命令</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Mongodb索引限制"><span class="nav-number">10.</span> <span class="nav-text">Mongodb索引限制</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Mongodb-MapReduce"><span class="nav-number">11.</span> <span class="nav-text">Mongodb MapReduce</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Mongodb-全文检索"><span class="nav-number">12.</span> <span class="nav-text">Mongodb 全文检索</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Mongodb-正则表达式"><span class="nav-number">13.</span> <span class="nav-text">Mongodb 正则表达式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Mongodb-固定集合"><span class="nav-number">14.</span> <span class="nav-text">Mongodb 固定集合</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">罗天翔</span>
</div>


<div class="powered-by">
  NBA & Code. What?
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  




  
    <script type="text/javascript">
    (function(){
      var appid = 'cyt9ceIwz';
      var conf = 'c6226e2bfb7e9c65efc235736edc5074';
      var width = window.innerWidth || document.documentElement.clientWidth;
      if (width < 960) {
      window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){
        window.changyan.api.config({appid:appid,conf:conf})});
      }
    })();
    </script>
    <script type="text/javascript" src="https://assets.changyan.sohu.com/upload/plugins/plugins.count.js"></script>
  




  





  

  

  

  

  

  

</body>
</html>
